import { get, post } from '@/utils/request';

export interface commentParams {
  start?: number;
  size?: number;
  feed_id?: string;
  content?: string;
  imgs?: string[];
  p_comment_id?: string; //    #被回复的评论id
  reply_to_uid?: string; // #被回复的评论用户id
  comment_id?: string;
  liked_uid?: string;
}

export interface CommentItem {
  comment_id?: string;
  content?: string;
  created_at?: number;
  feed_id?: string;
  imgs?: string[];
  like_count?: number;
  p_comment_id?: string;
  reply_flag?: number;
  reply_to_uid?: string;
  self_comment_flag?: boolean;
  status?: number;
  uid?: string;
  updated_at?: string;
  isShowReply?: boolean;
  showMoreChildReply?: boolean;
  user?: {
    uid?: string;
    avatar?: string;
    name?: string;
  };
  reply?: any[];
}

export class CommentAPI {
  // 发送评论
  static async sendComment(params: commentParams = {}) {
    const response = await post<any>('/feeds/comment', params);
    return response.data;
  }
  // 评论列表
  static async getCommentList(params: commentParams = {}) {
    const response = await post<any>('/feeds/get_comments', params);
    return response.data;
  }

  // 获取楼层回复列表
  static async getReplyCommentList(params: commentParams = {}) {
    const response = await post<any>('/feeds/reply_comments', params);
    return response.data;
  }

  // 删除评论
  static async deleteCommentList(params: commentParams = {}) {
    const response = await post<any>('/feeds/delete_comment', params);
    return response.data;
  }

  // 点赞
  static async isLike(params: commentParams = {}) {
    const response = await post<any>('/feeds/like', params);
    return response.data;
  }

  // 取消点赞
  static async unLike(params: commentParams = {}) {
    const response = await post<any>('/feeds/unlike', params);
    return response.data;
  }
}
